using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using RideMe.Core;
using RideMe.Presentation.ExceptionManagement;

namespace RideMe.Presentation
{
    public partial class ExceptionDialog : RideMe.Presentation.DialogBase
    {

        #region Fields

        private Exception _exception;

        #endregion

        #region Constructor

        public ExceptionDialog()
        {
            InitializeComponent();
        }

        #endregion

        #region Properties

        /// <summary>
        /// Gets or sets the exception.
        /// </summary>
        /// <value></value>
        public Exception Exception
        {
            get { return this._exception; }
            set { this._exception = value; }
        }

        #endregion

        #region Methods

        private void okButton_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void cancelButton_Click(object sender, EventArgs e)
        {
            ExceptionPublisher.SendBug(this.Exception);
        }

        #endregion

        #region Event Handlers

        /// <summary>
        /// Handles the LinkClicked event of the _exceptionDetailsLink control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="T:System.Windows.Forms.LinkLabelLinkClickedEventArgs"/> instance containing the event data.</param>
        private void _exceptionDetailsLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (this.Exception != null)
            {
                using (DebugExceptionDialog dialog = new DebugExceptionDialog(this.Exception))
                {
                    dialog.ShowDialog(this);
                }
            }
        }

        #endregion

    }
}

